<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="digital.store.tutorial.springmvc.model.User" %>
<%@ page import="digital.store.tutorial.springmvc.model.ShoppingCart" %>
<h1><fmt:message key="header.title"/></h1>
<div>
    <a style="margin-right: 10px; text-decoration: none; color: white" href="<c:url value='/' />">Home</a>
    <a style="margin-left: 950px; color:white">Welcome</a> |
     <% 	ShoppingCart mycart = (ShoppingCart)session.getAttribute("mycart");
    	if (mycart!=null) {
    		%>
    	<a href="<c:url value='/mycart'/>" >MyCart</a>
    <% 
    	}
    %> 
    <%	User user = (User)session.getAttribute("user");
    	if (user == null) {
    %>
    	<a style="color: white" href="<c:url value='/login'/>" >Login</a>
    <% } else {  
    	if (user.getId()==1){ %>
    	<a style="text-decoration: none" href="<c:url value='/admin'/>"> <%=user.getUsername() %> </a> |
    	<% } else { %>
    	<a style="text-decoration: none"> <%=user.getUsername() %> </a> |
    	<% } %>
   		<a style="text-decoration: none; color:white" href="<c:url value='/logout'/>">Logout</a>
 		<% } %>
</div>